<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<%@ include file="/common/taglibs.jsp" %>
<%@page contentType="text/html;charset=UTF-8"%>
<%@page pageEncoding="UTF-8"%>
<html>
<head>
    <title>权限管理</title>
    <script type="text/javascript" src="/static/scripts/auth/auth.thread.js"></script>
</head>
<body>

<input type="hidden" value='${ozingUsersJson}' id="usersJson"/>
<input type="hidden" value='${ozingRolesJson}' id="rolesJson"/>
<input type="hidden" value='${ozingResourcesJson}' id="resourcesJson"/>
<div class="yui-g">
    <select id="operation">
        <option value="user" selected="selected">用户<-->角色</option>
        <option value="role">角色<-->资源</option>
    </select>
    <form action="" id="authForm">
    <table style="border:1px solid #222;" width="1033">
        <tbody>
        <tr>
            <td style="width: 30%">用户</td>
            <td style="width: 30%">角色</td>
            <td style="width: 40%">资源</td>
        </tr>
        <tr>
            <td style="width: 30%">
                <table>
                    <tbody>
                        <tr>
                            <th>选择</th>
                            <th>用户名</th>
                        </tr>
                        <c:forEach items="${ozingUsers}" var="u" varStatus="status">
                        <tr>
                            <td>
                                <input type="hidden" value="${u.id}"/>
                                <input type="radio" id="user_${r.id}" value="${u.id}" name="ozingUserIds"/>
                            </td>
                            <td>${u.user.username}</td>
                        </tr>
                        </c:forEach>
                    </tbody>
                </table>
            </td>
            <td style="width: 30%">
                <table>
                    <tbody>
                        <tr>
                            <th>角色id</th>
                            <th>角色名</th>
                            <th>角色说明</th>
                        </tr>
                        <c:forEach items="${ozingRoles}" var="r" varStatus="status">
                            <tr>
                                <td>
                                    <input type="checkbox" id="role_${r.id}" value="${r.id}" name="ozingRoleIds" />
                                    <input type="radio" value="${r.id}" name="ozingRoleIds" style="display: none;"/>
                                </td>
                                <td>${r.name}</td>
                                <td>${r.description}</td>
                            </tr>
                        </c:forEach>
                    </tbody>
                </table>
            </td>
            <td style="width: 40%">
                <table>
                    <tbody>
                        <tr>
                            <th>资源名</th>
                            <th>资源url</th>
                            <th>资源说明</th>
                        </tr>
                        <c:forEach items="${ozingResources}" var="r" varStatus="status">
                            <tr>
                                <td>
                                    <input type="checkbox" id="resource_${r.id}" value="${r.id}" disabled="disabled" name="ozingResourceIds"/>
                                </td>
                                <td>${r.value}</td>
                                <td>${r.description}</td>
                            </tr>
                        </c:forEach>
                    </tbody>
                </table>
            </td>
        </tr>
        <tr>
            <td style="width: 30%">
                <input type="button" id="createUserBtn" value="新增用户" />
                <input type="button" id="saveUseRoleBtn" value="保存用户&角色" />
                <input type="button" id="deleteUserBtn" value="删除用户" />
            </td>
            <td style="width: 30%">
                <input type="button" id="createRoleBtn" value="新增角色" style="display: none;" />
                <input type="button" id="saveRoleResourceBtn" value="保存角色&权限" style="display: none;" />
                <input type="button" id="deleteRoleBtn" value="删除角色" style="display: none;" />
            </td>
            <td style="width: 40%"></td>
        </tr>
        </tbody>
    </table>
    </form>
</div>
</body>
</html>
